home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc1_2_x / inptmthd.sit / Input Methods / card_11494.txt < prev    next >
Text File  |  1989-11-24  |  3KB  |  120 lines

  1. -- card: 11494 from stack: in
  2. -- bmap block id: 11555
  3. -- flags: 4000
  4. -- background id: 2696
  5. -- name: Single Keypress
  6. ----- HyperTalk script -----
  7.  
  8. -- Thanks to Nigel Perry for the controlLock XCMD
  9. --   Department of Computing,Imperial College
  10. --   London,SW7England, email: np@uk.ac.ic.doc
  11.  
  12. on openCard
  13.   -- lock the stack on this card to make the letters fall faster
  14.   -- and to reduce disk access
  15.   set the cantModify of this stack to true
  16.   controlLock on  -- make keypresses generate controlKey message
  17.   pass openCard
  18. end openCard
  19.  
  20. on closeCard
  21.   set the cantModify of this stack to false  -- unlock the stack
  22.   controlLock off  -- turn key message thing off
  23.   cleanUp
  24.   pass closeCard
  25. end closeCard
  26.  
  27. -- A controlKey message is generated by any keypress
  28. on controlKey keyNum
  29.   global letterState, letterNum
  30.   if letterState = 100 then  -- letter is currently dropping
  31.     -- change lowercase to upper
  32.     if keyNum > 96 then subtract 32 from keyNum
  33.     if keyNum = letterNum then
  34.       rightSound
  35.       cleanUp
  36.     end if
  37.   end if
  38. end controlKey
  39.  
  40. on cleanUp
  41.   global letterState
  42.   put 0 into letterState
  43.   hide card field "Letter"
  44. end cleanUp
  45.  
  46. on idle
  47.   global letterState, letterNum, letterH, letterV
  48.   if letterState < 10 then  -- pause before dropping letter
  49.     add 1 to letterState
  50.   else if letterState Γëá 100 then  -- start dropping a new letter
  51.     put 100 into letterState
  52.     put 330 into letterH
  53.     put 120 into letterV
  54.     put random(26)+64 into letterNum  -- pick a random letter
  55.     put numToChar of letterNum into card field "Letter"
  56.   else  -- continue dropping
  57.     show card field "Letter" at letterH, letterV
  58.     add 20 to letterV
  59.     if letterV > 330 then  -- hit the bottom
  60.       hide card field "Cover"
  61.       play "Splat"
  62.       wait until the sound is "done"
  63.       cleanUp
  64.       show card field "Cover"
  65.     end if
  66.   end if
  67.   pass idle
  68. end idle
  69.  
  70.  
  71.  
  72. -- part 3 (field)
  73. -- low flags: 01
  74. -- high flags: 0001
  75. -- rect: left=286 top=305 right=339 bottom=371
  76. -- title width / last selected line: 0
  77. -- icon id / first selected line: 0 / 0
  78. -- text alignment: 0
  79. -- font id: 3
  80. -- text size: 12
  81. -- style flags: 0
  82. -- line height: 16
  83. -- part name: Cover
  84.  
  85.  
  86. -- part 1 (field)
  87. -- low flags: 80
  88. -- high flags: 0000
  89. -- rect: left=294 top=162 right=199 bottom=367
  90. -- title width / last selected line: 0
  91. -- icon id / first selected line: 0 / 0
  92. -- text alignment: 1
  93. -- font id: 3
  94. -- text size: 28
  95. -- style flags: 256
  96. -- line height: 37
  97. -- part name: Letter
  98.  
  99.  
  100. -- part 2 (field)
  101. -- low flags: 01
  102. -- high flags: 0002
  103. -- rect: left=16 top=131 right=170 bottom=230
  104. -- title width / last selected line: 0
  105. -- icon id / first selected line: 0 / 0
  106. -- text alignment: 0
  107. -- font id: 3
  108. -- text size: 14
  109. -- style flags: 0
  110. -- line height: 18
  111. -- part name: 
  112.  
  113.  
  114. -- part contents for card part 2
  115. ----- text -----
  116. Press the falling letter's key before it splats!
  117.  
  118. -- part contents for card part 1
  119. ----- text -----
  120. C